package com.dotflat.physicalevaluate.controller;


import com.alibaba.fastjson.JSON;
import com.dotflat.physicalevaluate.service.PhysicEvaluateExportService;
import com.tuo51.evaluate.service.EvaluateV2ExportService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

/**
 * 测评小程序使用的接口
 */

@Controller
@RequestMapping("/html/pe")
@Api(value = "/html/pe", tags = "PE - 体质评测H5报告")
public class ReportHTMLController {

    @Autowired
    private PhysicEvaluateExportService exportService;


    @RequestMapping(value = "/report",  method = GET)
    public String exportReport(Model model, String reportId) {

        Map detail = exportService.evaluateExportObject(reportId, null, null, null, EvaluateV2ExportService.ExportType.H5);

        String detailStr = JSON.toJSONString(detail);
        model.addAttribute("detail", detailStr);

        return "h5/report";
    }


}
